<template>
  <div>
      <h1>
          测试
        </h1>
        <p>store----测试</p>
        <div>$store.state.count:{{this.$store.state.count}}</div>
        <div>getters.getStateCount:{{this.$store.getters.getStateCount}}</div>
        <button @click="addFun">+</button>
        <button @click="reductionFun">-</button>
        <p>store----mapState,mapActions,mapGetters</p>
        <div>
          {{count1}}
        </div>

  </div>

</template>

<script>
  import {mapState,mapActions,mapGetters} from 'vuex'
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App'
    }

  },
  mounted() {
    console.log('mounted')
    this.$http.post('/lesson/getVideoUrl').then((res)=>{
      console.log(res);
    })
    /*axios.get('/lesson/getVideoUrl').then((res)=>{
      console.log(res);
    })*/
  },
  methods:{
      addFun(){
        // this.$store.commit('add');
        this.$store.dispatch('addFun');
      },
      reductionFun(){
        // this.$store.commit('reduction');
        this.$store.dispatch('reductionFun',10);
      }

    },
    computed: {
      ...mapState({
        count1:state=>state.count
      })
    },

}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
